package studio.raptor.extractor.sas;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.system.ApplicationPidFileWriter;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import studio.raptor.extractor.segment.ExtractorSegmentConfig;
import studio.raptor.extractor.segment.listeners.ExtractorApplicationListener;

/**
 * Created by liuyong8 on 2017/8/11.
 */
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackageClasses = {ExtractorSegmentConfig.class,SASExtractorServiceApplication.class })
public class SASExtractorServiceApplication extends SpringBootServletInitializer {

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return configureApplication(builder);
  }

  private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
    return builder
        .sources(SASExtractorServiceApplication.class)
        .listeners(new ApplicationPidFileWriter())
        .listeners(new ExtractorApplicationListener());
  }

  public static void main(String[] args) {
    configureApplication(new SpringApplicationBuilder()).run(args);
  }
}
